﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class Admin_HRManagement : System.Web.UI.Page
{
    AddminMethord AM = new AddminMethord();
    protected void Page_Load(object sender, EventArgs e)
    {
        viewallHR();
    }

    protected void btnSearch_Click(object sender, EventArgs e)
    {
        if (ddlSearch.SelectedItem.ToString().Equals("UserName"))
        {
            DataTable tb = AM.AdminSearchHR(txtsearch.Text);
            gvwHrManager.DataSource = tb.DefaultView;
            gvwHrManager.DataBind();
            for (int i = 0; i < tb.Rows.Count; i++)
            {
                gvwHrManager.Rows[i].Cells[4].Text = tb.Rows[i]["BirthOfDate"].ToString().Substring(0, tb.Rows[i]["BirthOfDate"].ToString().IndexOf(" "));
            }
        }
        else 
        {
            DataTable tb = AM.AdminSearchHrbyFulName(txtsearch.Text);            
            gvwHrManager.DataSource = tb.DefaultView;
            gvwHrManager.DataBind();
            for (int i = 0; i < tb.Rows.Count; i++)
            {
                gvwHrManager.Rows[i].Cells[4].Text = tb.Rows[i]["BirthOfDate"].ToString().Substring(0, tb.Rows[i]["BirthOfDate"].ToString().IndexOf(" "));
            }
        }
        

    }
    public void viewallHR() {
        DataTable tb = AM.AdminViewallHR();
        gvwHrManager.DataSource = tb.DefaultView;
        gvwHrManager.DataBind();
         for (int i = 0; i < tb.Rows.Count;i++ )
        {
            gvwHrManager.Rows[i].Cells[4].Text = tb.Rows[i]["BirthOfDate"].ToString().Substring(0,tb.Rows[i]["BirthOfDate"].ToString().IndexOf(" "));
        }
    }

}